<template>
  <div v-loading="loading" style="height: 100%; width: 100%"></div>
</template>
<script>
import { loginByToken } from "@/services/login";
export default {
  name: "loginByGitee",
  data() {
    return {
      loading: true,
    };
  },
  mounted() {
    this.loginByToken();
  },
  methods: {
    loginByToken() {
      let token = this.$route.query.token;
      sessionStorage.setItem("Authorization", token);
      const type = 0;
      loginByToken(type)
        .then((res) => {
          let userData = {
            username: res.data.username, //账号
            fullName: res.data.fullName, // 姓名
            headPic: res.data.headPic, // 头像
            endTime: res.data.endTime, //最新登录时间
            roleName: res.data.roleName, //角色
          };
          sessionStorage.setItem("userData", JSON.stringify(userData));
          this.$router.push("/");
        })
        .catch((error) => {
          this.$router.push("/login");
        });
    },
  },
};
</script>

<style scoped></style>
